#include<iostream>
#include<cstdio>
using namespace std;
int n=1,l,r,ans=-1;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	scanf("%d%d%d",&n,&l,&r);
	if(l<=n||n<=r-l+1){
		printf("%d",n-1);
		return 0;
	}
	for(int i=l;i<=r;i++){
		if(ans<=i%n){
			ans=i%n;
		}
		else{
			break;
		}
	}
	printf("%d",ans);
	return 0;
} 
